<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <!-- CSS -->
  <link rel="stylesheet" href="../../resources/css/bootstrap.min.css">
  <link rel="stylesheet" href="../../css/style.css">

</head>
<script type="text/javascript">

  window.onload=function(){
    // 登录form
    var login=document.getElementById("login_form");
    // 注册form
    var register=document.getElementById("register_form");
    var register_button=document.getElementById("register_button");
    register_button.onclick=function() {
      login.className = "form-signin hide";
      register.className = "form-sign";

      var register_submit = document.getElementById("register_submit");
      register_submit.onclick = function () {
        $("#rep_span").html("");
        var username = $("#register_username").val();
        var password = $("#register_password").val();
        var repassword = $("#register_repassword").val();
//                    if (username != "" && password != "" && repassword != "") {
        if (password != repassword) {
          $("#rep_span").removeClass("hidden");
          $("#rep_span").html("密码不一致");
          return false;
        }
        $("#register_form").submit();
//                    }
      }
    }

  }
  function refreshImage() {
    document.getElementById("captchaImage").setAttribute("src",
            "/Kaptcha.jpg?" + Math.round(Math.random() * 10000));
  }
  function loginForm(){
    return true;
  }
  //        function registerForm(){
  //            $("#rep_span").html("");
  ////            var username = $("#register_username").val();
  ////            var password = $("#register_password").val();
  //            if($("#register_password").val() != $("#register_repassword").val()){
  //                $("#rep_span").removeClass("hidden");
  //                $("#rep_span").html("密码不一致");
  //                return false;
  //            }
  //            $("#register").submit();
  //
  //        }
  /*var sign_sumbit = document.getElementById("#sign_submit");
   sign_sumbit.click(function(){
   var username = $("#register_username").val();
   var password = $("#register_password").val();
   $.ajax({
   url: '/register',
   type: 'post',
   async: true,
   dataType: 'json',
   data:{"username":username,"password":password},
   success: function (data) {
   alert(data);
   location.href="show.html";
   }
   });
   });*/
</script>
<body>

<div class="register-container" >
  <div class="register span6"  style="width:700px;">
    <form class="form-signin" id="login_form" action="" method="post">
      <h2>登  陆<span class="red"><strong>米米乐</strong></span></h2>
      <div class="form-group">
        <label for="username">用户名</label>
        <input type="text" id="username" name="username" placeholder="请输入用户名" required>
      </div>
      <div class="form-group">
        <label for="password">密&nbsp;&nbsp;&nbsp;码</label>
        <input type="password" id="password" name="password" placeholder="请输入密码" required>
      </div>
      <div class="form-group">
        <label for="check">验证码</label>
        <input type="text" id="check" name="check" placeholder="请输入验证码" required>
        <img src="/Kaptcha.jpg" id="captchaImage" onclick="javascript:refreshImage()"/>
      </div>
      <div class="form-group">
        <button type="submit" onclick="return loginForm();">登  陆</button>
        <button id="register_button" style="margin-top:2px;">注  册</button>
      </div>
    </form>

    <form class="form-sign hidden" id="register_form" action="/register" method="post">
      <h2>注  册<span class="red"><strong>米米乐</strong></span></h2>
      <div class="form-group">
        <label>用户名</label>
        <input type="text" id="register_username" name="username" placeholder="请输入用户名" required>
      </div>
      <div class="form-group">
        <label>密&nbsp;&nbsp;&nbsp;码</label>
        <input type="password" id="register_password" name="password" placeholder="请输入密码" required>
      </div>
      <div class="form-group">
        <label>确认密码</label>
        <input type="password" id="register_repassword" name="repassword" placeholder="请确认密码" required><span id="rep_span" class="hidden" style="color: red;"></span>
      </div>
      <button id="register_submit" type="submit" onclick="">提  交</button>
    </form>
  </div>

</div>
<!--data-toggle="modal" data-target="#signin"-->
<!--<div class="modal fade" id="signin" tabindex="-1" role="dialog">-->
<!--<div class="modal-dialog modal-lg">-->
<!--<div class="modal-content">-->
<!--<div class="modal-header">-->
<!--<button type="button" class="close" id="close" data-dismiss="modal">-->
<!--<span aria-hidden="true">&times;</span>-->
<!--<span class="sr-only">Close</span>-->
<!--</button>-->
<!--<h3 class="modal-title">注  册</h3>-->
<!--</div>-->
<!--<div class="modal-body register span6" style="width:900px;">-->
<!--<form class="form-sign" id="register" action="" method="post">-->
<!--<h2>登  陆<span class="red"><strong>米米乐</strong></span></h2>-->
<!--<div class="form-group">-->
<!--<label>用户名</label>-->
<!--<input type="text" id="register_username" name="username" placeholder="请输入用户名" required>-->
<!--</div>-->
<!--<div class="form-group">-->
<!--<label>密&nbsp;&nbsp;&nbsp;码</label>-->
<!--<input type="password" id="register_password" name="password" placeholder="请输入密码" required>-->
<!--</div>-->
<!--<div class="form-group">-->
<!--<label>确认密码</label>-->
<!--<input type="password" id="register_repassword" name="repassword" placeholder="请确认密码" required><span id="rep_span" class="hidden" style="color: red;"></span>-->
<!--</div>-->
<!--<button id="sign_submit" type="submit" onclick="return registerForm()">提  交</button>-->
<!--</form>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!--</div>-->
<!-- Javascript -->
<script src="../../resources/js/jquery-1.8.2.min.js"></script>
<script src="../../resources/js/bootstrap.min.js"></script>
<script src="../../resources/js/jquery.backstretch.min.js"></script>
<script src="../../resources/js/scripts.js"></script>
</body>
</html>
